
var INOUT_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS INOUT (id INTEGER PRIMARY KEY AUTOINCREMENT,kind,firstname,lastname,amount,unit,startDate,endDate,comment)";
var ARCHIVES_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS ARCHIVES(id INTEGER PRIMARY KEY AUTOINCREMENT,kind,firstname,lastname,amount,unit,startDate,endDate,archiveDate,comment)";
var dbShell;

function initDB(){

	dbShell = window.openDatabase("mainDB", "1","MoneyIODB",10000 );
    dbShell.transaction(createTables,errorCB,successCB);
    dbShell.transaction(queryDBHomeEntries,errorCB);
}

function createTables(tx){
	tx.executeSql(INOUT_TABLE_CREATE);
	tx.executeSql(ARCHIVES_TABLE_CREATE);
}

/**
 * Functions for ARCHIVE Entries
 */
function displayArchiveEntries(){
	dbShell.transaction(queryDBArchiveEntries,errorCB);
}

function queryDBArchiveEntries(tx){
	tx.executeSql('SELECT * FROM ARCHIVES',[],querySuccessArchiveEntries,errorCB);
}

function querySuccessArchiveEntries(tx, results){
	insertEntriesInDOM (results, "#archives");
	
}

